package com.turnengine.client.global.announcement.command;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * The Get Announcement Count.
 */
public class GetAnnouncementCount implements IGetAnnouncementCount {

	/** The command id. */
	public static final short COMMAND_ID = 102;

	/** The game id. */
	private int gameId;

	/**
	 * Creates a new Get Announcement Count.
	 */
	public GetAnnouncementCount() {
	}

	/**
	 * Creates a new Get Announcement Count.
	 * @param gameId the game id
	 */
	public GetAnnouncementCount(int gameId) {
		setGameId(gameId);
	}

	/**
	 * Creates a new Get Announcement Count.
	 * @param iGetAnnouncementCount the i get announcement count
	 */
	public GetAnnouncementCount(IGetAnnouncementCount iGetAnnouncementCount) {
		setGameId(iGetAnnouncementCount.getGameId());
	}

	/**
	 * Returns the game id.
	 * @return the game id.
	 */
	public int getGameId() {
		return gameId;
	}

	/**
	 * Sets the game id.
	 * @param gameId the game id to set.
	 */
	public void setGameId(int gameId) {
		this.gameId = gameId;
	}

	/**
	 * Returns the hash code.
	 * @return the hash code.
	 */
	@Override
	public int hashCode() {
		HashCodeBuilder hash = new HashCodeBuilder(13, 37);
		hash.append(gameId);
		return hash.toHashCode();
	}

	/**
	 * Returns true if this is equal to the given object.
	 * @param object the object to compare.
	 * @return true if this is equal to the given object.
	 */
	@Override
	public boolean equals(Object object) {
		if (object == this) {
			return true;
		}
		if (object instanceof GetAnnouncementCount) {
			GetAnnouncementCount compare = (GetAnnouncementCount) object;
			EqualsBuilder equals = new EqualsBuilder();
			equals.append(this.gameId, compare.gameId);
			return equals.isEquals();
		}
		return false;
	}

	/**
	 * Compare this to the given object.
	 * @param compare the object to compare to.
	 * @return the result of the comparison.
	 */
	@Override
	public int compareTo(IGetAnnouncementCount compare) {
		CompareToBuilder builder = new CompareToBuilder();
		builder.append(this.gameId, compare.getGameId());
		return builder.toComparison();
	}

	/**
	 * Returns this as a string.
	 * @return this as a string.
	 */
	@Override
	public String toString() {
		ToStringBuilder string = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
		string.append("gameId", gameId);
		return string.toString();
	}

	public short getCommandId() {
		return COMMAND_ID;
	}
}
